/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Golf_Manager.model;

import Golf_Manager.vo.GroupDesc;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Administrator
 */
public class GroupDescModel extends AbstractTableModel {
    
    Class[] types = new Class [] {java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.Integer.class };
    private List<Golf_Manager.vo.GroupDesc> groupDescs = new ArrayList<>();
    private String[] columns = new String [] {"조편성일자", "조편성기준", "정렬기준", "최근전적반영여부"};
    private boolean[] canEdit = new boolean [] { false, false, false, false };
    
    @Override
    public Class<?> getColumnClass(int columnIndex) {
        return types[columnIndex];
    }
    
    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return canEdit[columnIndex];
    }
    
    @Override
    public int getRowCount() {
        return groupDescs.size();
    }

    @Override
    public int getColumnCount() {
        return columns.length;
    }
    
    @Override
    public String getColumnName(int column) {
        return columns[column];
    }
    
    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        switch(columnIndex){
            case 0: {
                return groupDescs.get(rowIndex).getgDate();
            }
            case 1: {
                return groupDescs.get(rowIndex).getgKey();
            }
            case 2: {
                return groupDescs.get(rowIndex).getgOrder();
            }
            case 3: {
                return groupDescs.get(rowIndex).getgRecYn();
            }
            default: {
                return null;
            }
        }
    }

    public List<GroupDesc> getGroupDescs() {
        return groupDescs;
    }

    public void setGroupDescs(List<GroupDesc> groupDescs) {
        this.groupDescs = new ArrayList<>(groupDescs);
        fireTableDataChanged();
    }
    
    public GroupDesc getGroupDesc(int rowIndex) {
        return groupDescs.get(rowIndex);
    }
    
    
    
}
